﻿using HCQ2_IBLL;
using HCQ2_Model.VRDD.InputDto._211026;
using HCQ2_Model.VRDD.OutputDto._211026;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace HCQ2_BLL
{
    public partial class T_VRPlayListBLL: IT_VRPlayListBLL
    {
        /// <summary>
        ///  获取点播列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<OutputPlayTable> GetPlayTable(QueryPlayTable param)
        {
            var list = DBSession.IT_VRPlayListDAL.GetPlayTable(param);
            if (list == null || list.Count <= 0)
                return null;
            List<int> ids = list.Select(s => s.id)?.ToList();
            list.ForEach(s => {
                var pic = DBSession.IT_VRPlayPictureListDAL.Select(o => o.playId == s.id);
                List<PictureListModel> l = new List<PictureListModel>();
                pic?.ForEach(n => l.Add(new PictureListModel { PictureUrl = n.pictureUrl.Replace("~", HttpContext.Current.Request.Url.AbsoluteUri.Substring(0, HttpContext.Current.Request.Url.AbsoluteUri.IndexOf("/api/"))) }));
                s.PictureList = l;
            });
            return list;
        }

        /// <summary>
        ///  后台初始化点播列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="rows"></param>
        /// <param name="playStatus"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        public List<OutputPlayList> GetPlayList(int page, int rows, int playStatus, string userName, out int total)
        {
            return DBSession.IT_VRPlayListDAL.GetPlayList(page, rows, playStatus, userName, out total);
        }
    }
}